package pers.litao.bit.user.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import pers.litao.bit.commons.utils.R;
import pers.litao.bit.user.service.AddressService;

import javax.servlet.http.HttpServletRequest;

/**
 * @author 李涛
 * @date 2020-12-08 18:46
 */
@RestController
@RequestMapping("/user/address")
public class AddressController {

    @Autowired
    private AddressService addressService;

    /**
     * 获取用户地址
     *
     * @param userId
     * @return
     */
    @RequestMapping(value = "/getuseraddress/{id}",method = RequestMethod.GET)
    public R getAddress(@PathVariable("id") Long userId){
        return addressService.getUserAddress(userId);
    }

    /**
     * 获取所有地址,内部调用
     *
     * @return
     */
    @RequestMapping("/getAddressAll")
    public R getAddressAll(){
        return R.ok(addressService.list());
    }
}
